home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: presby.edu!jtbell
- From: jtbell@presby.edu (Jon Bell)
- Subject: Re: Class
- Message-ID: <Dnr1Bv.Jy9@presby.edu>
- Date: Mon, 4 Mar 1996 15:21:30 GMT
- References: <4hchoh$ngh@nova.umuc.edu> <DnpEHt.BH3@presby.edu> <HEYDENJ.96Mar4095800@bothrops.natlab.research.philips.com>
- Organization: Presbyterian College, Clinton, South Carolina USA
-
- Heijden van der J. <heydenj@bothrops.natlab.research.philips.com> wrote:
- >The #ifndef / #define / #endif is used to prevent a single header to be
- >included more then once (a header file might already be included in one of
- >the other header files you include.
-
- Yes, this trick will prevent any function definitions in the header file
- from being compiled more than once, *provided* that the main program has
- only one source file that #includes EmpRecords.h.
-
- But if there are two or more source files, and both of them #include
- EmpRecords.h, for example:
-
- g++ foo.cc -c
- g++ bar.cc -c
- g++ foo.o bar.o -o foobar
-
- or even just
-
- g++ foo.cc bar.cc -o foobar
-
- (I'm assuming that EmpRecords.cc has already been compiled.)
-
- If both foo.cc and bar.cc #include EmpRecords.h, and EmpRecords.h
- contains actual function definitions, then those functions will be
- compiled twice and you will probably get a warning from the linker about
- "duplicate symbols" or some such thing.
-
- --
- Jon Bell <jtbell@presby.edu> Presbyterian College
- Dept. of Physics and Computer Science Clinton, South Carolina USA
-